package com.hollycrm.hollysqm.core.index.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hollycrm.hollysqm.core.index.service.IndexSearchService;
import com.hollycrm.hollysqm.core.index.service.impl.I8IndexSearchServiceImpl;
import com.hollycrm.hollysqm.core.index.service.impl.V8IndexSearchServiceImpl;
import com.hollycrm.hollysqm.util.Constant;

/**
 * 索引工厂类
 * @author jianglong
 * @date 2017年3月29日 下午4:04:37
 */
@Service
public class IndexSearchFactory {

	/**
	 * I8索引对象
	 */
	@Autowired
	private I8IndexSearchServiceImpl i8IndexSearchService;
	
	/**
	 * V8索引对象
	 */
	@Autowired
	private V8IndexSearchServiceImpl v8IndexSearchService;
	
	/**
	 * 获取指定索引对象
	 * @param tag
	 * @return
	 */
	public IndexSearchService getNewIndexService(final String tag){
		if (Constant.V8.equalsIgnoreCase(tag)){
			return getV8IndexService();
		}else if (Constant.I8.equalsIgnoreCase(tag)) {
			return getI8IndexService();
		}
		return null;
	}
	
	/**
	 * 获取V8索引对象
	 * @return
	 */
	public IndexSearchService getV8IndexService(){
		v8IndexSearchService.setCollection();
		return v8IndexSearchService;		
	}
	
	/**
	 * 获取I8索引对象
	 * @return
	 */
	public IndexSearchService getI8IndexService(){
		i8IndexSearchService.setCollection();
		return i8IndexSearchService;
	}
	
}
